//
//  NNSegmentLabel.swift
//  DYLive
//
//  Created by 众力金融 on 2019/5/8.
//  Copyright © 2019 众力金融. All rights reserved.
//

import UIKit

class NNSegmentLabel: UILabel {
    
    open var fillColor : UIColor = UIColor.red //填充色
    open var defaultColor : UIColor = UIColor.black
    open var LabelIsTitleZoomEnabled = false
    open var titleSelectedScale:CGFloat = 0.0
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        textAlignment = .center
        backgroundColor = .clear
        isUserInteractionEnabled = true
    }
    
    required init?(coder aDecoder: NSCoder) {
       super.init(coder: aDecoder)
    }
    
    func scale(scale: CGFloat) {
        
        textColor = NNSegmentedViewTool.interpolateColor(from: defaultColor, to: fillColor, precent: scale)
        
        if LabelIsTitleZoomEnabled {
            // 大小缩放比例
            let transformScale = 1 + scale * titleSelectedScale
            self.transform = CGAffineTransform(scaleX: transformScale, y: transformScale)
        }
       
    }

}
